package com.ruoyi.web.controller.wf;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.framework.responseBodyJson.JSON;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.yf.domain.Report;
import com.ruoyi.yf.domain.YfTag;
import com.ruoyi.yf.service.IWfTagService;
import com.ruoyi.yf.service.IYfTagService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/wf/manager")
public class WfTagController extends BaseController {

    private String prefix = "wf";

    @Autowired
    private IWfTagService wfTagService;


    // 跳转到危废院端主页
    @GetMapping("")
    public String hospitalWfMain() {
        return prefix + "/hospital_wf_main";
    }



    // 跳转到危废联单
    @GetMapping("/wfTag")
    public String sanitationTagManger() {
        return prefix + "/wf_tag";
    }


    // 查询危废列表
    @RequiresPermissions("yf:tag:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(YfTag yfTag) {
        startPage();
        List<YfTag> list = wfTagService.selectWfTagList(yfTag);
        return getDataTable(list);
    }



    // 左图上 - 危废产量（不包含医废）
    @PostMapping("/echarets/hospital_bag_and_weight")
    @JSON(type = Report.class, include = "id,name,d1,l1,d2,l3,d3,d4,l4,l5")
    public AjaxResult bagandweight(@RequestParam Long deptId) {
        Long udeptId = ShiroUtils.getSysUser().getDeptId();
        Report report = wfTagService.bagandweight(deptId != null ? deptId : udeptId);
        if (report != null) {
            return AjaxResult.successful(report);
        }
        return error();
    }


    // 右图上 - 科室危废占比（不包含医废）
    @PostMapping("/echarets/dept_trash_sum_staging")
    @JSON(type = Report.class, include = "l1,name,d1,i1,d2,i2,d3,i3,d4,i4")
    public TableDataInfo dept_trash_sum_staging(@RequestParam Long deptId) {
        Long udeptId = ShiroUtils.getSysUser().getDeptId();
        List<Report> list = wfTagService.dept_trash_sum_staging(deptId != null ? deptId : udeptId);
        return getDataTable(list);
    }


    // 左图下 - 近一周危废采集趋势图（不包含医废）
    @PostMapping("/echarets/gathering_week_of_statistics")
    @JSON(type = Report.class, include = "id,s1,name,sum,count,d1,d2,d3,d4,d5,d6,d7,i1,i2,i3,i4,i5,i6,i7")
    public TableDataInfo gathering_week_of_statistics(@RequestParam Long deptId) {
        Long udeptId = ShiroUtils.getSysUser().getDeptId();
        List<Report> list = wfTagService.gathering_week_of_statistics(deptId != null ? deptId : udeptId);
        return getDataTable(list);
    }


    // 右图下 - 危废类别日暂存、产量统计（不包含医废）
    @PostMapping("/echarets/now_day_trash_type_sum_staging")
    @JSON(type = Report.class, include = "s1,name,d1,l1,d2,l3")
    public TableDataInfo now_day_trash_type_sum_staging(@RequestParam Long deptId) {
        Long udeptId = ShiroUtils.getSysUser().getDeptId();
        List<Report> list = wfTagService.now_day_trash_type_sum_staging(deptId != null ? deptId : udeptId);
        return getDataTable(list);
    }



}
